<?php

namespace App\Http\Requests\Admin\ActivityPerRedPacket;

use App\Http\Requests\Request;

class UpdateRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
//        dd($this->all());
        return [
            'name'=>'required',
            'address'=>'required',
            'contact'=>'required',
            'mobile' => 'bail|required_without:area_code|digits:11',
            'area_code' => 'bail|required_without:mobile|required_with:phone|digits:4',
            'phone'=>'bail|required_without:mobile|required_with:area_code|digits_between:7,8',
            'money'=>'required|integer',
            'account_balance'=>'integer',
            'receive_num'=>'integer',
            'use_num'=>'integer',
            'download'=>'integer',

        ];
    }
    public function messages()
    {
        return [
            'name.required'=>'商户名称必须填写',
            'address.required'=>'商户地址必须填写',
            'contact.required'=>'商户联系人必须填写',
            'mobile.required_without'=>'商户手机和电话号码必须填写一个',
            'mobile.digits'=>'电话号码必须为11位',
            'area_code.required_without'=>'商户手机和电话号码必须填写一个',
            'area_code.required_with'=>'电话号码必须填写',
            'area_code.digits'=>'区号必须为4位',
            'phone.required_without'=>'商户手机和电话号码必须填写一个',
            'phone.required_with'=>'电话号码必须填写',
            'phone.digits_between'=>'电话号码必须是7~8位',
            'money.required'=>'单个红包金额必须填写',
            'money.integer'=>'单个红包金额必须是数字',
            'account_balance.integer'=>'商户账户余额必须是数字',
            'receive_num.integer'=>'累计领取金额必须是数字',
            'use_num.integer'=>'累计使用金额必须是数字',
            'download.integer'=>'累计下载数必须是数字',
        ];
    }
}
